-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2536 Document Versioned API Usage #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PYTHON-2536 Document Versioned API Usage #584
Conversation
pymongo/server_api.py
Outdated
|
||
>>> client = MongoClient(server_api=ServerApi('1', strict=True)) | ||
>>> server_api=ServerApi('1', strict=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server_api=ServerApi
-> server_api = ServerApi
>>> server_api=ServerApi('1', deprecation_errors=True) | ||
>>> client = MongoClient(server_api=server_api) | ||
|
||
Note that at the time of this writing, no deprecated APIs exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an example of what a deprecation would look like? Would it be an OperationFailure error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> client.db.command(command={'testDeprecationInVersion2': 1, 'apiVersion': '2', 'apiDeprecationErrors': True})
...
pymongo.errors.OperationFailure: Provided apiDeprecationErrors:true, but the command testDeprecationInVersion2 is deprecated in API Version 2, full error: {'ok': 0.0, 'errmsg': 'Provided apiDeprecationErrors:true, but the command testDeprecationInVersion2 is deprecated in API Version 2', 'code': 324, 'codeName': 'APIDeprecationError', '$clusterTime': {'clusterTime': Timestamp(1617170403, 1), 'signature': {'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0}}, 'operationTime': Timestamp(1617170403, 1)}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reluctant to include this as an example because the server needs to be started with special testing parameters enabled to be able to see this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
>>> server_api=ServerApi('1', deprecation_errors=True) | ||
>>> client = MongoClient(server_api=server_api) | ||
|
||
Note that at the time of this writing, no deprecated APIs exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
pymongo/server_api.py
Outdated
@@ -27,6 +27,8 @@ | |||
Declaring an API Version | |||
```````````````````````` | |||
|
|||
.. attention: Versioned API requires MongoDB >=5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this render correctly? Other places we use two colons:
.. attention:: ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed and confirmed that it renders correctly.
(cherry picked from commit 1882e99)
No description provided.